﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace HRProject.Code.DTO
{
    public class BLOverWorktime
    {
        private Guid id;
        private string startTime;
        private string endTime;
        private Guid updateUserId;
        private DateTime updateDate;
        private long dataSignature;

        public long DataSignature
        {
            get { return dataSignature; }
            set { dataSignature = value; }
        }

        public DateTime UpdateDate
        {
            get { return updateDate; }
            set { updateDate = value; }
        }

        public Guid UpdateUserId
        {
            get { return updateUserId; }
            set { updateUserId = value; }
        }

        public Guid Id
        {
            get { return id; }
            set { id = value; }
        }

        public string EndTime
        {
            get { return endTime; }
            set { endTime = value; }
        }

        public string EndTimeStandard
        {
            get
            {
                string result = string.Empty;
                try
                {
                    int endHour = int.Parse(endTime.Substring(0, 2));
                    int endMin = int.Parse(endTime.Substring(3, 2));
                    if (endHour > 23)
                    {
                        endHour -= 24;
                    }
                    return (endHour.ToString("00") + ":" + endMin.ToString("00"));
                }
                catch (Exception exp)
                {
                    exp.GetHashCode();
                }
                return result;
            }
        }

        public string StartTime
        {
            get { return startTime; }
            set { startTime = value; }
        }

        public float Total
        {
            get
            {
                float result = 0;
                try
                {
                    int startHour = int.Parse(startTime.Substring(0, 2));
                    int startMin = int.Parse(startTime.Substring(3, 2));
                    int endHour = int.Parse(endTime.Substring(0, 2));
                    int endMin = int.Parse(endTime.Substring(3, 2));
                    result = (endHour * 60 + endMin - startHour * 60 - startMin) / 480F;
                }
                catch (Exception exp)
                {
                    Console.Out.WriteLine(exp.Message);
                }
                return result;
            }
        }
    }
}
